/**
 *
 */
package anysware.source;

import java.util.Collection;

import org.springframework.transaction.annotation.Transactional;

import anysware.source.dao.SourceDao;

/**
 * TODO: doc me
 *
 * @author keke<keke@codehaus.org>
 * @revision $Revision: 111 $
 * @version
 */
public class DefaultSourceService implements SourceService {
	private SourceDao	sourceDao;

	@Transactional(readOnly = false)
	public void delete(final Source source) {
		sourceDao.delete(source);

	}

	/*
	 * (non-Javadoc)
	 *
	 * @see anysware.source.SourceService#getAllSources()
	 */
	@Transactional(readOnly = true)
	public Collection<Source> getAllSources() {
		return sourceDao.listAll();
	}

	@Transactional(readOnly = true)
	public Source getSource(final String name) {
		return sourceDao.getSourceByName(name);
	}

	@Transactional(readOnly = true)
	public Collection<Source> getSourceByType(final String type) {
		return sourceDao.getSourcesByType(type);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see anysware.source.SourceService#save(anysware.source.Source)
	 */
	@Transactional(readOnly = false)
	public Source save(final Source source) {
		sourceDao.save(source);
		return source;
	}

	/**
	 * @param sourceDao
	 *            the sourceDao to set
	 */
	public void setSourceDao(final SourceDao sourceDao) {
		this.sourceDao = sourceDao;
	}

}
